/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.football.lottery.dao;

import com.football.lottery.util.JDBCUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.openide.util.Exceptions;

/**
 *
 * @author JingWen.Wen
 */
public class ForecastDaoImpl implements ForecastDao
{
  public Connection getConnection()
  {
    return JDBCUtil.getPGConnection();
  }

  @Override
  public List getAllAuthor()
  {
    try
    {
      Connection conn = this.getConnection();
      String sql = "SELECT author FROM recommended GROUP BY author";
      
      PreparedStatement pst = conn.prepareStatement(sql);
      List authors = new ArrayList();
      
      ResultSet rs = pst.executeQuery();
      while (rs.next())
      {
        authors.add(rs.getString(1));
      }
      
      return authors;
    }
    catch (SQLException ex)
    {
      Exceptions.printStackTrace(ex);
      return new ArrayList();
    }
  }

  @Override
  public List getAllProvenance()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public List getAllType()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public Map getForecastDataGroupByAuthor()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }

  @Override
  public Map getForecastDataGroupByType()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }
  
}
